#ifndef __BINARTREE_H_
#define __BINARTREE_H_

#include <iostream>
#include <MyInclude/LinkQueue.h>

class BinarTree
{
public:
    using ElementType = int;
    
    BinarTree();
    ~BinarTree();

    void Insert(const ElementType& element);
    ElementType* Find(const ElementType& element);
    void Remove(const ElementType& element);
    void show();



private:
    struct TreeNode
    {
        TreeNode(const ElementType& element)
        {
            data = element;
            left = right = nullptr;
        }
        ElementType data;
        TreeNode *left;
        TreeNode *right;
    };
    TreeNode* InsertNode(TreeNode *node,const ElementType& element);
    void PrevSort(TreeNode *node);
    void MidSort(TreeNode *node);
    void PostSort(TreeNode *node);
    void Free(TreeNode *node);
    ElementType* FindNode(TreeNode *node,const ElementType& element);
    TreeNode* RemoveNode(TreeNode *node,const ElementType& element);
    TreeNode* GetMinNode(TreeNode* node);
    TreeNode *root;
};


#endif